//
//  MPBidTableEmptyView.m
//  M800Project
//
//  Created by 姚宗超 on 14/11/10.
//  Copyright (c) 2014年 姚宗超. All rights reserved.
//

#import "MPBidTableEmptyView.h"

@interface MPBidTableEmptyView ()
@property (nonatomic, strong)UIImageView* addBtnIconView;
@property (nonatomic, strong)UILabel* describLabel;
@property (nonatomic, strong)UILabel* addBtnLabel;
@property (nonatomic, strong)UIView* addBtnView;

@end

@implementation MPBidTableEmptyView

- (instancetype)init
{
    return [self initWithFrame:CGRectZero];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        //
        [self.addBtnView addSubview:self.addBtnIconView];
        [self.addBtnView addSubview:self.addBtnLabel];
        
        [self.addBtnIconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.centerY.mas_equalTo(self.addBtnView);
            make.width.height.mas_equalTo(@25.0f);
        }];
        [self.addBtnLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(self.addBtnIconView.mas_trailing).with.offset(10.0f);
            make.centerY.trailing.mas_equalTo(self.addBtnView);
            make.top.mas_equalTo(self.addBtnView).with.offset(10.0f);
        }];
        
        [self addSubview:self.describLabel];
        [self addSubview:self.addBtnView];
        
        [self.describLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_equalTo(self);
            make.width.mas_equalTo(SCREEN_WIDTH - 40.0f);
        }];
        
        [self.addBtnView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.bottom.mas_equalTo(self);
            make.top.mas_equalTo(self.describLabel.mas_bottom).with.offset(30.0f);
        }];
        
        UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];
        [self.addBtnView addGestureRecognizer:tap];
    }
    return self;
}

- (void)tapGestureHandler:(UITapGestureRecognizer *)tap
{
    if (self.tapHandler) {
        self.tapHandler();
    }
}

#pragma mark - property
- (UIImageView *)addBtnIconView
{
    if (!_addBtnIconView) {
        _addBtnIconView = [[UIImageView alloc] initWithImage:[UIImage imageForKey:@"bid_addbtn_icon"]];
    }
    return _addBtnIconView;
}

- (UILabel *)describLabel
{
    if (!_describLabel) {
        _describLabel = [[UILabel alloc] init];
        _describLabel.font = [UIFont systemFontOfSize:kDescribeFontSize];
        _describLabel.textColor = [UIColor colorWithHexString:kTextUnSelectedGrayColor];
        _describLabel.text = @"当前没有合适的项目。您也可以通过点击下方按钮，修改筛选条件，关注更多热标";
        _describLabel.textAlignment = NSTextAlignmentCenter;
        _describLabel.numberOfLines = 0;
    }
    return _describLabel;
}

- (UILabel *)addBtnLabel
{
    if (!_addBtnLabel) {
        _addBtnLabel = [[UILabel alloc] init];
        _addBtnLabel.font = [UIFont systemFontOfSize:kTitleFontSize];
        _addBtnLabel.textColor = [UIColor colorWithHexString:kTopBarBgColor];
        _addBtnLabel.text = @"设置P2P抢标规则";
    }
    return _addBtnLabel;
}

- (UIView *)addBtnView
{
    if (!_addBtnView) {
        _addBtnView = [[UIView alloc] init];
    }
    return _addBtnView;
}

@end
